import javax.swing.*;
import java.awt.event.ActionEvent;

public class Test {
    public static void main(String[] args) {
        JFrame win = new JFrame("登录界面");
        JPanel jPanel = new JPanel();
        win.add(jPanel);

        JButton btn = new JButton("登录");
        win.add(btn);

        //给按钮绑定单击事件监听器;
        btn.addActionListener(new AbstractAction() {
            @Override
            public void actionPerformed(ActionEvent e) {
                JOptionPane.showConfirmDialog(win,"欢迎登录");
            }
        });
        //匿名内部类的核心目的是:简化代码


        win.setSize(500,500);
        win.setLocationRelativeTo(null);
        win.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
        win.setVisible(true);
    }
}
